// Copyright (c) 2007 Alistair Jones
// This program is made available under the terms of the MIT License.
package org.hypirinha.html.codegen;

import java.io.File;
import java.io.PrintStream;
import java.io.FileOutputStream;
import java.util.List;

public class CodeGenerator {
    
    public static void main(String[] args) throws Exception {
        List<CompilationUnit> compilationUnits = new ElementGenerator().generate();
        compilationUnits.addAll(new AttributeGenerator().generate());

        File outputDirectory = new File("target/generated/java");

        for (CompilationUnit generatedInterface : compilationUnits) {
            File outputFile = new File(outputDirectory, generatedInterface.getFileName());
            outputFile.getParentFile().mkdirs();
            PrintStream printStream = new PrintStream(new FileOutputStream(outputFile));
            generatedInterface.printTo(printStream);
            printStream.close();
        }
    }
}